import { request } from "@utils/http"
import { IDepartmentList, IDictList, IDoctorList, IHospitalDetailResponse, IHospitalListParams, IHospitalListResponse, IScheduleResponse } from "./model/hospitalListTypes"

/**
 * 获取 省 市 区 列表
 *     86  
 * @param value 
 * @returns 
 */
export const getDictList = (value: string) => {
    return request.get<any, IDictList>(`/admin/cmn/dict/findByParentId/${value}`)
}
/**
 * 医院列表分页数据获取
 * @param param0  {page:当前页,limit:每页显示几条......}
 * @returns Promise<IHospitalListResponse>
 */
export const getHospitalList = ({
    page,
    limit,
    hoscode,
    hosname,
    hostype,
    provinceCode,
    cityCode,
    districtCode,
    status
}: IHospitalListParams)=>{
    return request.get<any, IHospitalListResponse>(`/admin/hosp/hospital/${page}/${limit}`, {
        params: {
            hoscode,
            hosname,
            hostype,
            provinceCode,
            cityCode,
            districtCode,
            status
        }
    })
}

/**
 * 根据id获取医院详情数据
 * @param id 
 * @returns Promise<IHospitalDetailResponse>
 */
export const getHospitalDetail = (id:string)=>{
    return request.get<any, IHospitalDetailResponse>('/admin/hosp/hospital/show/' + id)
}
/**
 * 修改状态
 * @param id 
 * @param status 
 * @returns 
 */
export const changeState = (id:string,status:number)=>{
    return request.get<any,null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`)
}
/**
 * 获取科室列表
 * @param hoscode 
 * @returns Promise<IDepartmentList>
 */
export const getDepartmentList = (hoscode:string)=>{
    return request.get<any,IDepartmentList>('/admin/hosp/department/' + hoscode)
}

/**
 * 获取医院某科室的排班日期分页数据
 * @param page  当前页
 * @param limit 每页显示几条
 * @param hoscode  医院编号
 * @param depcode  科室编号
 * @returns Promise<IScheduleResponse>
 */
export const getScheduleList = (page:number, limit:number, hoscode:string, depcode:string)=>{
    return request.get<any, IScheduleResponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)
}
/**
 * 根据 医院code， 科室code ，日期获取排班医生列表
 * @param hoscode 医院编号
 * @param depcode 科室编号
 * @param workDate 日期
 * @returns Promise<IDoctorList>
 */
export const getDoctorList = (hoscode:string, depcode:string, workDate:string)=>{
    return request.get<any, IDoctorList>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)
}